package com.fezs.common.constants;

import com.fezs.common.exception.ServerException;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
 * @author zhukai
 * @since 2022/8/18
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CacheConstant {

    public static final String LOGIN_USER = "LOGIN_USER";

    public static final String USER_PERMISSION = "USER_PERMISSION";

    public static final String USER_ROLE = "USER_ROLE";

    public static final String RATE_LIMIT = "RATE_LIMIT";

    public static final String LOCK_KEY_PREFIX = "LOCK4J";

    public static String contact(Object... strs) {
        if (strs == null || strs.length == 0) {
            throw new ServerException("缓存键不能为空");
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < strs.length; i++) {
            sb.append(strs[i]);
            if (i != strs.length - 1) {
                sb.append(":");
            }
        }
        return sb.toString();
    }

}
